Repository navigation
Move duplicated adapter code into core - #522
Merged
Merged
Conversation
This was referenced Oct 30, 2026
The same logic sat in two or three adapters word for word, so a change to it had to land in every copy, which is CLAUDE.md's rule for core: - The screencast recorder's start, stop and unavailable log lines were written by each adapter's subclass; ScreencastRecorderBase now writes them through a logger each adapter supplies, keeping its logger name. - Selenium and Nightwatch built their BiDi console and network sinks the same way; buildBidiSinks is now in core, with Selenium's console evidence latch passed in as a hook, since only Selenium has one. Within one adapter: Selenium's mocha, cucumber and jest hooks share one run summary; Selenium's and Nightwatch's PluginInternals extend the context types they repeated; Nightwatch builds its captured and replaced command rows through one helper; the WDIO launcher and standalone mode share their argv parsing, in a module of its own so the launcher's rerun patch never reaches the worker bundle. Kept: each adapter's attachBidiHandlers only binds its own logger name, and the types.ts files re-export shared types under stable local names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vishnuv688
force-pushed
the
refactor/library-duplicates
branch
from
October 30, 2026 10:13
aea93af to
7aa154b
Compare
vishnuv688
force-pushed
the
refactor/adapter-duplicates-to-core
branch
from
October 30, 2026 10:13
2b01d71 to
f00bd8d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Closes #528 (the last of three cleanup PRs). Part of #494. Stacked on #521.
A duplicate-block scan found the same code in two or three adapters, word for word, plus repeats inside single adapters. Each true duplicate now lives once. No behaviour change: log text, logger names and every adapter's BiDi attach behaviour are as before.
Type of change
Packages touched
shared(types and contracts)core(framework-agnostic capture/reporting)elements(published element/snapshot API —@wdio/elements)service(WebdriverIO adapter)nightwatch-devtools(Nightwatch adapter)selenium-devtools(Selenium adapter)selenium-devtools-py(Selenium Python adapter)backend(server)app(UI)script(page-injected runtime)trace(Trace mode)Capability matrix
packages/conformance/src/features.tsupdated, and tables regenerated withpnpm docs:capabilities, if this adds or changes user-facing behaviourNot needed: no behaviour change.
Notes for reviewers
Why this is in
core, though it touches every adapter: the screencast lifecycle logging existed in three adapters and the BiDi sink wiring in two, word for word, so a change to either had to land in every copy, which is CLAUDE.md's rule forcore. Each adapter still owns what is its own: its logger name, Nightwatch's screenshot transport, and Selenium's console evidence latch.ScreencastRecorderBasewrites them through aloggereach adapter sets (ScreencastLogger), so logger names are unchanged; no logger means silent, as beforebuildBidiSinksbidiConsoleObserved) stays in Selenium, passed in asonConsoleEntry. Each adapter'sattachBidiHandlerswrapper stays: it only binds its logger namerunnerHooks/run-summary.ts(jest's log text is identical, as it always reports 0 pending)PluginInternalsrepeating their context typesextendsthe context interfaces, redeclaring only fields whosereadonlydiffers. Type-only#commandEntry; a retry still keeps the previous row's idservice/src/invocation-args.ts, its own module because the launcher patcheshttp.Server.prototype.listenat load during a rerun, which must not reach the worker bundletypes.tsScan, pairs involving an adapter: 14 before, 2 after (the
types.tsre-exports, and the backend vs Nightwatch config-file search kept in #521).New core exports:
ScreencastLogger,buildBidiSinks,BidiSinkTarget. The one renamed function,detectInvocationConfigPathtoconfigPathFromArgv, was documented as not public API, so no changeset. None of these has a Python mirror.Testing
pnpm install --frozen-lockfile,pnpm build,pnpm test(3437 passed, twice, to rule out the flaky conformance failure seen once while developing) andpnpm lintare green..js/.cjsfile in the service, Selenium and Nightwatch bundles searched, none found.buildBidiSinkshook order, latch, and replace vs append; the run summary lines and payload.Screenshots / recordings
Not applicable: no UI change.
🤖 Generated with Claude Code